package com.serviceprovider.business.module.order.services.impl;

//~--- non-JDK imports --------------------------------------------------------

import com.serviceprovider.business.module.order.model.OrderFilter;
import com.serviceprovider.business.module.order.services.dao.interfaces.IOrderFilterDao;
import com.serviceprovider.business.module.order.services.interfaces.IOrderFiltersService;
import com.serviceprovider.business.module.order.valueobjects.OrderFilterVO;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

//~--- JDK imports ------------------------------------------------------------

import java.util.ArrayList;
import java.util.List;

@Service
public class OrderFiltersServiceImpl implements IOrderFiltersService {
    @Autowired
    private IOrderFilterDao orderFilterDao;

    @Override
    public List<OrderFilterVO> findAll() {
        List<OrderFilterVO> result = new ArrayList<OrderFilterVO>();
        List<OrderFilter>   list   = orderFilterDao.findAll();

        for (OrderFilter item : list) {
            result.add(new OrderFilterVO(item));
        }

        return result;
    }

    @Override
    public void addNew(OrderFilterVO entity) {
        orderFilterDao.createNew(new OrderFilter(entity));
    }

    @Override
    public OrderFilterVO getById(Integer id) {
        OrderFilter entity = orderFilterDao.getById(id);

        return new OrderFilterVO(entity);
    }

    @Override
    public void update(OrderFilterVO entity) {
        orderFilterDao.update(new OrderFilter(entity));
    }

    @Override
    public void removeById(Integer id) {
        orderFilterDao.removeById(id);
    }

    @Override
    public List<OrderFilterVO> findAllActive() {
        List<OrderFilterVO> result = new ArrayList<OrderFilterVO>();
        List<OrderFilter>   list   = orderFilterDao.findAllActive();

        for (OrderFilter item : list) {
            result.add(new OrderFilterVO(item));
        }

        return result;
    }
}



